A Lil insight into the Python Print function

print is an inbuilt python function that writes to the console. What the print writes to the console depends on what is given to it to print. The print function can writes data such as integers, strings, boolean, lists etc. Practically waht so ever you give to the print function, it will write it out for the user to see....

read more about the print function on the www.python.org website

Usage


In [1]:
print "Hello World"


Hello World

Hands On

  1. Create a file and call it "script.py" (this is just a name we using for now so we can be on the same page. You call the file any name u want just make sure it has the .py extension)
  2. In script.py write: print "Hello World"
  3. Save the file
  4. Open the Command prompt and navigate to the folder where you have the file (script.py)
  5. Run this command: 'python script.py' without the quotes
  6. Hello World should be printed to the console (All things being equal)

Practice

Create a file (give it any name you want but make sure it has the .py extension)

In the File

  1. Create 10 variables (give them any name you want)
  2. Assign to each variable any data type value you want (make sure you use all the data types you know) example of data types are integers, strings, lists, set, dictionary, boolean etc
  3. Write a print for each variable
  4. Open your Command line and run the script

Submit

Submit your answer to the group for review

Disclaimer

For further errors contact us (on the Group)

Next

Running Functions